<?php


namespace Drupal\shushengyuan\Schemas;

use Drupal\shusy_gift_card\Entity\ShusyGiftCard;

/**
 * @OA\Schema(
 *   schema="MyGiftCard",
 *   type="object",
 *   description="MyGiftCard",
 * )
 */
class MyGiftCard extends AbstractBaseModel {

  protected function getEntityType() {
    return 'shusy_gift_card';
  }

  protected function setValue() {
    if ($this->entity instanceof ShusyGiftCard) {
      $value = [
        /**
         * @OA\Property(
         *   property="id",
         *   type="integer",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity->id,
        /**
         * @OA\Property(
         *   property="name",
         *   type="string",
         *   description="名称",
         * ),
         */
        'name' => (string) $this->entity->name,
        /**
         * @OA\Property(
         *   property="image",
         *   type="string",
         *   description="封面图",
         * ),
         */
        'image' => $this->imageStyleUrl('MyGiftCardImage', $this->wrapper->field_image->value()),
        /**
         * @OA\Property(
         *   property="amount",
         *   type="number",
         *   description="面额",
         * ),
         */
        'amount' => $this->convertYuan($this->entity->amount),
        /**
         * @OA\Property(
         *   property="status",
         *   type="integer",
         *   description="状态 0 未使用 1 已使用",
         * ),
         */
        'status' => (int) $this->entity->status,
      ];
      $this->merge($value);
    }
  }

}
